<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang='en'>
<head>
	<meta charset='utf-8' />
	<title>广溢信息技术有限公司</title>
	<meta content='' name='description' />
	<meta content='' name='author' />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- Bootstrap -->
	<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" >
    <link href="__PUBLIC__/css/jquery-ui-1.9.2.custom.css" rel="stylesheet" />
	<link href="__PUBLIC__/css/font-awesome.min.css" rel="stylesheet" >

	<!--[if IE 7]>
		<link  href="__PUBLIC__/css/font-awesome-ie7.min.css" rel="stylesheet">
	<![endif]-->

	<!--[if lt IE 9]>
		<link type="text/css" href="__PUBLIC__/css/custom-theme/jquery.ui.1.9.2.ie.css"  rel="stylesheet" />
	<![endif]-->

	<link href="__PUBLIC__/css/bootstrap-responsive.css" rel="stylesheet">
	<link href="__PUBLIC__/css/test.css" rel="stylesheet">
	<script src="__PUBLIC__/js/jquery.js"></script>

	<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	<script src="__PUBLIC__/js/html5shiv.js"></script>
	<script src="__PUBLIC__/js/respond.min.js"></script>
	<![endif]-->
	<script type="text/javascript">
	var upload_url="<?php echo U('file/upload?module='.MODULE_NAME);?>";
	var del_url="<?php echo U('File/del');?>";
	var session_id="<?php echo session_id();?>";	
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?2a935166b0c9b73fef3c8bae58b95fe4";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
</script>
</head>
<body>
	<div class="shade"></div>
	<div class="row-fluid navbar visible-phone">
	<div class="row-fluid">
		<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
		<a data-toggle="collapse" data-target="#top_menu" class="right">
		<i class="brand icon-th-list"></i>
		</a>
	</div>
	<div class="col-lapse" id="top_menu">
		<ul class="nav nav-pills">
			<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
					<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
				</li><?php endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>
</div>
<div class="row-fluid navbar hidden-phone">
	<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
	<ul class="nav nav-pills">
		<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
				<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
			</li><?php endforeach; endif; else: echo "" ;endif; ?>
	</ul>
	<aside>
		<span>
			<a href="<?php echo U('UserConfig/index');?>">设置</a>
		</span>
		<span>
			<a href="<?php echo U('profile/index');?>"><?php echo (session('user_name')); ?></a>
		</span>
		<span>
			<a href="<?php echo U('login/logout');?>">退出</a>
		</span>
		&nbsp;&nbsp;
	</aside>
</div>

	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span2 left_menu">
				<div class="visible-phone">
	<h4 class="btn no-border" data-toggle="collapse" data-target="#left_menu">		
			<?php echo ($top_menu_name); ?><i class="icon-angle-down"></i>
		</h4>
	<div class="col-lapse" id="left_menu"><?php echo ($html_left_menu); ?></div>
</div>
<div class="hidden-phone">
	<h4><?php echo ($top_menu_name); ?></h4>
	<div><?php echo ($html_left_menu); ?></div>
</div>
			</div>
			<div class="span10 content">
<script type="text/javascript">
	function add() {
    var cate = '<?php echo $cate ?>';
    var add_url = 'add/cate/'+cate;
		window.open("<?php echo U('"+add_url+"');?>", "_self");
	}

	function edit() {
		id = $("li.tbody.active :checkbox").val();
		if (id == undefined) {
			alert("请选择要编辑的对象");
			return false;
		} else {
			window.open(fix_url("<?php echo U('edit');?>?id=" + id), "_self");
		}
	}

	function del() {
		if(confirm('确定要删除吗?')){
		if ($("#form_data .table input:checked").length == 0) {
			$("li.tbody.active :checkbox").attr("checked", true);
		}
		sendForm("form_data", "<?php echo U('del');?>");
		$("#form_data input:checked").each(function() {
			$(this).parents("li").remove();
		})
		}
	}

	function apply() {
		if ($("#form_data .table input:checked").length == 0) {
			$("li.tbody.active input:checkbox").attr("checked", true);
		}
		sendForm("form_data", "<?php echo U('set_tag');?>","__URL__");
	}

	function create_new_tag() {
		$(".customer .cmd").hide();
		$(".customer .new_tag").css("display", "block");
		$(".customer .apply").show();
	}


	function key_search_2(inp) {
    /*
    alert(search_txt);
		if (event.keyCode == 13){
			$(".table li").hide();			
			val = $("#keyword").val().toUpperCase();
			if (val.length == 0) {
				$(".title nobr").html("全部");
			} else {
				$(".title nobr").html("搜索结果");
			}
			$(".table li .data").each(function() {
				if ($(this).text().indexOf(val) >= 0) {
					$(this).parents("li").show();
				};
			})
		}
    */
	}

	function btn_search_2() {		
    
		var	search_txt = $("#keyword").val();
    //alert(search_txt);
    var url = '<?php echo U("") ?>';
    //alert(url);
    $.ajax({
      url: url,    
      data: {search_txt: search_txt},
      dataType: 'html',
      type: "POST",
      cache: false,
      async: true,
      success: function(html){
     //   alert(html);
        $('#content').html(html); 
        return false;
      }
    });
    /*
    $(".table li").hide();			
		val = $("#keyword").val().toUpperCase();
		if (val.length == 0) {
			$(".title nobr").html("全部");
		} else {
			$(".title nobr").html("搜索结果");
		}
		$(".table li .data").each(function() {
			if ($(this).text().indexOf(val) >= 0) {
				$(this).parents("li").show();
			};
		})		
    */
	}
	
	function move_to(val) {
		if (val != '') {
			sendAjax("<?php echo U('mark');?>", 'val=' + val + '&id=' + $("#customer_id").val(), function(data) {
				if (data.status) {
					$("#form_search").submit();
				}
			});
		} else {
			$("#form_search").submit();
		}
	}
	
	function export_customer(){
		window.open("<?php echo U('export');?>","_blank");
	}

	function import_customer(){
		window.open("<?php echo U('import');?>","_self");
	}

	$(document).ready(function() {
		set_return_url();
		$(".dropdown-menu.title li").click(function() {
			$("#keyword").val("");
			$(".table li").hide();
			gid = $(this).attr("gid");
			$(".title nobr").html($(this).text());
			$(".table li div.tag").each(function() {
				if ($(this).text().indexOf(gid) >= 0) {
					$(this).parents("li").show();
				};
			})
		})
		$(".table input:checkbox").click(function(e) {
			$("li.tbody.active").removeClass("active");
			$(".tag_list input[name='tag[]']").attr("checked", false);
			$("li.tbody input:checked").each(function() {
				$(this).parents("li.tbody").addClass("active");
			})
			e.stopPropagation();
		})
		$(".tag_list input:checkbox").bind("change propertychange", function() {
			$(".customer .cmd").hide();
			$(".customer .apply").show();
		})
		$(".tag_list li,.dropdown-menu .cmd li,.new_tag input").click(function(e){
			e.stopPropagation();
		})	

		$("li.tbody").click(function() {
			$("li.tbody.active").removeClass("active");
			$(this).addClass("active");
			$(".table input:checkbox").attr("checked", false);
			$(".tag_list input[name='tag[]']").attr("checked", false);
			str=trim($(this).find(".tag").text());
			strs=str.split(","); 
			for (i=0;i<strs.length;i++)    
			 {  
				 $(".tag_list input[name='tag[]'][value='"+strs[i]+"']").attr("checked",true);
			}
		})			
	}); 
</script>
<div class="customer">
	<div class="row-fluid title">
		<div class="btn-group">
			<span class="btn dropdown-toggle no-border" data-toggle="dropdown" href="#">
				<nobr>全部</nobr> <i class="icon-caret-down"></i>
			</span>
			<ul class="dropdown-menu title">
				<li gid="">
					<a>全部</a>
				</li>
				<?php if(is_array($tag_list)): foreach($tag_list as $key=>$vo): ?><li gid="<?php echo ($key); ?>">
						<a><?php echo ($vo); ?></a>
					</li><?php endforeach; endif; ?>
			</ul>
		</div>
		<div class="input-append right">
			<input type="text"  onkeydown="key_search_2(this);" name="keyword" id="keyword">
			<a class="btn" onclick="btn_search_2();"> <i class="icon-search"></i>
			</a>
		</div>
	</div>
	<form id="form_data" name="form_data" method='post'>
		<div class="operate row-fluid">
			<div class="left">
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						管理
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li>
							<a onclick="manage_tag();">管理组</a>
						</li>
						<li>
							<a onclick="import_customer();">导入</a>
						</li>
						<li>
							<a onclick="export_customer();">导出</a>
						</li>
					</ul>
				</div>
				<a class="btn" onclick="edit();">编辑</a>
				<a class="btn"onclick="del();" >删除</a>
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						组
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu tag_list">
						<li class="disabled">
							<a>添加到</a>
						</li>
						<?php if(is_array($tag_list)): foreach($tag_list as $key=>$vo): ?><li>
								<a>
									<label class="checkbox">
										<input type="checkbox" name="tag[]" value="<?php echo ($key); ?>"><?php echo ($vo); ?></label>
								</a>
							</li><?php endforeach; endif; ?>
						<li class="new_tag">
							<input type="text" name="new_tag" class="input-medium"></li>
						<li class="divider"></li>
						<li class="apply">
							<input class="btn" type="button" value="应用" onclick="apply();"></li>
						<li class="cmd">
							<input class="btn input-mini" type="button" onclick="create_new_tag();" value="新组"></li>
					</ul>
				</div>
			</div>
			<div class="right">
				<a class="btn" onclick="add();">新建</a>
			</div>
		</div>
		<div id="list" name="list" class="table">
			<ul>
				<?php if(count($list) == 0 ): ?><li class="tbody text-center">
						<h3>没找到相应的数据</h3>
					</li>
				</ul>
			</div>
			<?php else: ?>
      <div id="content">
        <?php if(is_array($list)): foreach($list as $key=>$vo): ?><li  class="tbody">
<div class="data" style="display:none"><?php echo ($vo["letter"]); ?></div>
<div class="tag" style="display:none">
  <?php echo ($tag_data[$vo["id"]]) ?>
</div>
<div class="row-fluid">
  <span class="span6" style="padding-left:30px;">
    <span class="checkbox">
      <input type="checkbox" name="customer_id[]" value="<?php echo ($vo["id"]); ?>" >	
    </span>							
    <nobr class="data"><?php echo C('CATE')[$vo[cate]];?></nobr>
  </span>
  <span class="span6"  style="padding-left:10px;">
    <a href="<?php echo U('read?id='.$vo['id']);?>" class="data"><?php echo ($vo["name"]); ?></a>
  </span>
</div>
<!--<div class="row-fluid">-->
  <!--<span  class="span6 "  style="padding-left:10px;">-->
    <!--<nobr>联系人：</nobr>-->
    <!--<nobr class="data"><?php echo ($vo["contact"]); ?></nobr>-->
  <!--</span>-->
  <!--<span  class="span6"  style="padding-left:10px;">-->
    <!--<nobr>电话：</nobr>-->
    <!--<nobr class="data">-->
    <!--<?php echo ($vo["office_tel"]); ?>-->
    <!--<?php if(!empty($vo["mobile_tel"])): ?>/ <?php echo ($vo["mobile_tel"]); endif; ?>-->
    <!--</nobr>-->
  <!--</span>-->
<!--</div>-->
</li><?php endforeach; endif; ?>
<div id="page">
  <?php echo ($page); ?>
</div>

      </div> 

		</ul>
	</div>
</form><?php endif; ?>
</div>
</div>
		</div>
	</div>
	<div class="msg popout"></div>
	<iframe src="<?php echo U('push/client');?>" class="push" id="push"></iframe>
	<script src="__PUBLIC__/js/bootstrap.min.js"></script>
	<script src="__PUBLIC__/js/jquery-ui-1.9.2.custom.min.js"></script>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>